import java.util.HashSet;
import java.util.Set;

public class Main20250326 {
}

class Solution {
    public int minimumSum(int n, int k) {
        Set<Integer> set = new HashSet<>();
        int i = 1;
        while (set.size() != n) {
            if (!set.contains(k - i)) {
                set.add(i);
            }
            i++;
        }
        return set.stream().reduce(0, (a, b) -> a + b);
    }

    public int minimumSum(int n, int k) {
        int x1 = k / 2;
        if (x1 <= n) {
            return (n + 1) * n / 2;
        }
        int sum1 = (x1 + 1) * x1 / 2;
        int sum2 = (n - x1) * k + (n - x1) * (n - x1 - 1) / 2;
        return sum1 + sum2;
    }
}